<html>
	<head>
		<script>

			function onLoad() {
			}

			function testSubmission() {
				var element = document.getElementById("layerElement");
				layer = element.value;
				
				element = document.getElementById("keyElement");
				key = element.value;
				
				element = document.getElementById("featureElement");
				feature = element.value;
				
				var url = "feature/" + layer + "/" + key;
				submit("PUT",url,feature,uploadComplete);
			}
			
			function uploadComplete(result) {
				alert("Upload complete");
			}

			function submit(method,url,body,onDownload) {

				var xmlhttp = new XMLHttpRequest();

				xmlhttp.onreadystatechange=function() {
					if (xmlhttp.readyState==4 && xmlhttp.status==200) {
						onDownload(xmlhttp.responseText);

					}
					else if(xmlhttp.readyState==4) {
						alert("Error in request, Status: " + xmlhttp.status);
					}
				}

				xmlhttp.open(method,url,true);
				xmlhttp.send(body);
			}

			function clearResult() {
				$("#resultDiv").html("");
			}

		</script>
	</head>
	<body onload="onLoad()">
		<h1>Feature Upload Test</h1>
		layer: <textarea id="layerElement" cols="31"></textarea><br>
		key: <textarea id="keyElement" cols="31"></textarea><br>
		feature: <textarea id="featureElement" cols="70" rows="20"></textarea><br>
		<input type="button" value="Submit" onclick="testSubmission()"/>
	</body>
</html>
